package com.yt.system.controller;


import com.yt.system.domain.GroupTable;
import com.yt.system.domain.ObjectiveKeyresults;
import com.yt.system.domain.User;
import com.yt.system.service.GroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("小组功能")
@RequestMapping("/group")
@RestController
public class GroupController {
    @Autowired
    GroupService groupService;

    //1.查所有组名
    @ApiOperation(value = "查所有组名")
//    @GetMapping("/getGName")
    @RequestMapping(value = "/getGName",method = RequestMethod.GET)
    @ResponseBody
    public List<GroupTable> selectGName(){
        return groupService.selectGName();
    }

    //2.根据小组id查询uid，uname
    @ApiOperation(value = "根据小组id查询uid，uname")
    @RequestMapping(value = "/getGroup/{gid}",method = RequestMethod.GET)
//    @GetMapping("/getGroup/{gid}")
    @ResponseBody
    public List<User> selectGroup(@PathVariable("gid") int gid){
        return groupService.selectGroup(gid);
    }

    //4.根据小组id查询okr
    @ApiOperation(value = "根据小组id查询okr")
    @RequestMapping(value = "/getOkrBygid/{gid}",method = RequestMethod.GET)
//    @GetMapping("/getOkrBygid/{gid}")
    @ResponseBody
    public List<ObjectiveKeyresults> selectOkr(@PathVariable("gid") int gid){
        return groupService.selectOkr(gid);
    }

    //5.根据小组id查成员okr
    @ApiOperation(value = "根据小组id查成员okr")
    @RequestMapping(value = "/getUserOkr/{gid}",method = RequestMethod.GET)
//    @GetMapping("/getUserOkr/{gid}")
    @ResponseBody
    public List<ObjectiveKeyresults> selectOkrByUid(@PathVariable("gid") int gid){
        return groupService.selectOkrByGid(gid);
    }




}
